"""
https://blog.csdn.net/qq_46111316/article/details/120188504
"""
import cv2 #opencv读取的格式是BGR
import matplotlib.pyplot as plt
import numpy as np 

img_path = "/Users/mac/Documents/Learning/LearningOpencv/datasets/1.jpg"
save_path = "/Users/mac/Documents/Learning/LearningOpencv/datasets/1_test.jpg"

img = cv2.imread(img_path)
print(img.shape)

img_gray = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)   # 灰色
img_color = cv2.imread(img_path, cv2.IMREAD_COLOR)    # 彩色 
img_hsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)    # HSV：H色调(主波长);S饱和度(纯度/颜色的阴影);V值(强度)

#显示图像。waitKey(0) 等待时间，毫秒级，0表示任意键终止
cv2.imshow('image',img) 
cv2.imshow('img_gray',img_gray) 
cv2.imshow('img_color',img_color) 
cv2.imshow('img_hsv',img_hsv) 
cv2.waitKey(0) 


#保存
cv2.imwrite(save_path,img)
print(type(img))       # numpy.ndarray
print(img.dtype)       # dtype('uint8')
